<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="include :: header"></head>
<body>
<form class="layui-form" style="padding: 15px;">
    <div class="layui-inline">
        <label class="layui-form-label">来源名称</label>
        <div class="layui-input-inline">
            <select id="source">
                <option value="">全部</option>
                <option value="01">餐饮</option>
                <option value="02">购物</option>
                <option value="03">交通</option>
                <option value="04">娱乐</option>
                <option value="05">通讯</option>
                <option value="10">可支配</option>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">财务类别</label>
        <div class="layui-input-inline">
            <select id="type">
                <option value="">全部</option>
                <option value="01">支出</option>
                <option value="10">可支配</option>
            </select>
        </div>
    </div>
    <button class="layui-btn layui-btn-sm"><i class="layui-icon"></i>
    </button>
</form>

<table id="balanceList" class="layui-hide" lay-filter="balance"></table>

<script type="text/html" id="toolbarTable">
    <button class="layui-btn layui-btn-sm" shiro:hasPermission="system:balance:add"
            onclick="openWindow('添加支出信息','/venus/project/balance/add')"><i
            class="layui-icon"></i>添加
    </button>
    <button class="layui-btn layui-btn-sm"
            onclick="openWindow('统计','/venus/project/balance/charts')">统计表格
    </button>
</script>

<script type="text/html" id="toolbar">
    <a class="layui-btn layui-btn-xs" lay-event="edit" shiro:hasPermission="system:balance:edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" shiro:hasPermission="system:balance:del">删除</a>
</script>
<div th:include="include :: footer"></div>

<script>
    var sysUrl = '/venus/project/balance';
    layui.use(['table'], function () {
        var table = layui.table;
        table.render({
            id: 'balanceList',
            elem: '#balanceList',
            method: 'post',
            height: 'full-100',
            toolbar: '#toolbarTable',
            defaultToolbar: ['print', 'exports'],
            cellMinWidth: 100,
            url: sysUrl + '/list',
            cols: [
                [
                    {field: 'num', width: 50, title: '序号', type: 'numbers'},
                    {
                        field: 'source', width: 150, title: '来源名称', templet: function (d) {
                            var source = d.source;
                            if (source === "01") {
                                return "餐饮";
                            } else if (source === "02") {
                                return "购物";
                            } else if (source === "03") {
                                return "交通";
                            } else if (source === "04") {
                                return "娱乐";
                            } else if (source === "05") {
                                return "通讯";
                            } else if (source === "10") {
                                return "可支配";
                            }
                        }
                    },
                    {
                        field: 'type', width: 150, title: '财务类别', templet: function (d) {
                            var type = d.type;
                            if (type === "01") {
                                return "<span style='color: #ff0000;'>支出</span>";
                            } else if (type === "10") {
                                return "<span style='color: #008000;'>可支配</span>";
                            }
                        }
                    },
                    {field: 'account', width: 150, title: '财务账户'},
                    {field: 'money', width: 150, title: '金额（元）'},
                    {
                        field: 'recordDate', width: 180, title: '核算日期', templet: function (d) {
                            return getDateStr(d.recordDate);
                        }
                    },
                    {field: 'remark', title: '备注'},
                    {fixed: 'right', title: '操作', width: 150, toolbar: "#toolbar"}
                ]
            ]
            , page: true
        });

        //监听行工具事件
        table.on('tool(balance)', function (obj) {
            delAndEdit(sysUrl, obj, 'balance');
        });
        //搜索
        $('.layui-form .layui-btn').on('click', function () {
            table.reload('balanceList', {
                where: {
                    type: $("#type").val(),
                    source: $("#source").val()
                }
            });
            return false;
        });
    });
</script>
</body>
</html>